/*
 * stackAndQueueNode.cpp
 *
 *  Created on: Aug 20, 2012
 *      Author: xkq
 */

#include <iostream>
#include "LinkedListNode.h"
using namespace std;

class stack {
	Node* top;

	int pop() {
		if (top != NULL) {
			int result = top->data;
			top = top->next;
			return result;
		}
		return -1;
	}

	void push(int num) {
		Node *node = new Node();
		node->data = num;
		node->next = top;
		top = node;
	}

	int peek() {
		return top->data;
	}

};

class queue{
	Node *first, *last;

	void enqueue(int num){
		if(!first){
			last = new Node();
			last->data = num;
			first = last;
		}else{
			last->next = new Node();
			last->next->data =num;
			last = last->next;
		}
	}

	int dequeue(){
		if(first!=NULL){
			int result = first->data;
			first = first->next;
			return result;
		}
		return -1;
	}
};


